from docker import DockerClient


class Singleton:
    def __init__(self, cls):
        self._cls = cls
        self._instance = {}

    def __call__(self):
        if self._cls not in self._instance:
            self._instance[self._cls] = self._cls()
        return self._instance[self._cls]


@Singleton
class Client():
    client: DockerClient

    def __init__(self) -> None:
        self.client = DockerClient(base_url='unix://var/run/docker.sock')
